import dither from './dither.ts'
import initTransmitter from './transmit.ts'

const ADDRESS = '192.168.178.200'
const DISPLAY_SIZE = [800, 480]
const imgSrcPath = Deno.args[0]
const imgDstPath = Deno.args[1]

// Learn more at https://deno.land/manual/examples/module_metadata#concepts
if (import.meta.main) {
  if (!imgSrcPath) {
    console.error('Usage: deno main.ts <input-path> [output-path]')
  } else {
    const [w, h] = DISPLAY_SIZE
    const transmit = initTransmitter(ADDRESS)
    const imageData = await dither(imgSrcPath, w, h, imgDstPath)

    transmit(imageData, w, h)
  }
}
