From 15177f67c9f97d542437e40d98b384abf288c743 Mon Sep 17 00:00:00 2001 From: Matthew Frost Date: Sat, 18 Nov 2023 16:05:11 +0100 Subject: [PATCH] remove crap --- kia.png | Bin 4722 -> 0 bytes stickerimg.go | 181 ------------------------------------------ dim.go => test_dnh.go | 0 trash.go | 95 ---------------------- 4 files changed, 276 deletions(-) delete mode 100644 kia.png delete mode 100644 stickerimg.go rename dim.go => test_dnh.go (100%) delete mode 100644 trash.go diff --git a/kia.png b/kia.png deleted file mode 100644 index 0cf3643df263ded2bd142a2a342d2979a8ca547d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4722 zcmV-&5{>PNP)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FZT01FZU(%pXi00007bV*G`2iyb= z6bvm~hY&mf01@&@L_t(|+U=ToSe11a$3N%2mmM)lB^^`LG9g<`%bGT|y-`yT$}I)U z6lzMAG=;Rl9W=`|6HF5m0d=0S(Q?UVS~N?0T+r0qQ&CV*)_d=J=8t>9eVK_cpPBR5 zU4Gm9eb4ee=ltOR@&}MnS$6>NZuTGUXi}rQCFcmR9;Get3yC4k|7d_%Yj!)ey1-C` zz(1n$8a29`i4BqIfS{cIKOj~UO#X@pKxwtDo0N5(0x~QN4D6^L1pKRU<;Ems4!aRiLo9Si|`Z4IX7HifV>qBqPZYKa`u4V7QPq5f`5W)T|^WG6wCDm z2!N80C@3R&H@n^i|Btvzelolp?9NL8ETG2_=|Eyg{&m4a!WhgVCON-MTNXrqc@r@9 zfTn`wBftZ+3^;<}IEJI>7vAo71!tNQi0}*OamuX?NP5n}uv_eR~U|L zhKC$+fdGjiFh1Lza>+;37bK8`kbO1AR3nKajg;+|QBgsl2%wx&3jsa@DJ`3dryW{Yg!|p#VT*9nkM>5JdY*do-W`s>gNXe-5<)hR zlpPHWL!==}Dv2R+HBQ|liR}$^Q)E~=DLbxaPCw!v08*ZMV%_%8uzxnQ+gW8DM6zu< zLj=aEq9O=zvv(8+E9aF>1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igl!3nw&eC?^yS6|W$~IwSzKfD$44!?x&f+Gr+)YJqZcUVC9az>HZGW?{N}B3u?4L)Q=d_ zNZA&-Ev}B~L0f>93t{{7=ZvC($aSbZ6#{a5 zUW5;P4BPuw&G{S9+0`R1%-u78shXajlNg#&<3;95Nh4*i=TZN){@*v>88n~gF7W*G z@dMt)S$wWAt+YHJ3|GE$(iPuTp}rv(e_54aIH&NnIvYEp&_Rdy>IX88|(ga>B_)#w?gZ9Dm zDN`X-1Ut}rYcFR+xQr~TGUO`&lG_7<=F`cv*9zMA>&O;}!;VTZB87+qgB~V1`|h(U zYBl3S&f_mPsm1)_+l)y&3_A}a)Kf)($5#5CsdcDJ(MT|>_GC#groVd?O|3$YKV zmG@oUHh?0of8Q$HDWRs5r0&E$bFtsSZQNg*)IkI=?cMD@co0fYSBAgD(fTrK<-7=Szc6W$hb7AQIm0%3R(!dLm^cVZ`0~% zw`ahL&yRN4cArtf%v!!ITK62psRj~AW1bMMij z;Qa-~fqD53-_i>Ad_QlmU;T}fckTVc&C2GVcI12t*5%;HA+g(zD)#X^-X{IcD-U1@ zA2NiDLX{4S7hVw$+8I6h$00{(|fZPb`0aC0ulG8{Dh#=;kbSC~- zHQ~Rc;x!J4i@ranFi)TsX!kTyuXs26C5G@3<1SX5>J7|u5>;uI#)Li8p!_C4hB1u8 zl-~lf6X%u9!ZcFrR0F`PfexVU(nwujlYsoDusfR32;z1oiIwfY^+5fI2Xuz>PKew} z4NGgwysWPT4YnhI*Dv$a1fl6d2P8jw=V12}KGh`<*PZ07$o zAfGbPt{9CJ+NY5^u> 8 & 255), - byte(y & 255), byte(y >> 8 & 255), - byte(width & 255), byte(width >> 8 & 255), - byte(height & 255), byte(height >> 8 & 255)} -} -func offsetY(offset int) []byte { - // A positive number specifies movement downward, and a negative number specifies movement upward. - // The horizontal or vertical motion unit is used for the print direction set by ESC T. - // When the starting position is set to the upper left or lower right of the print area using ESC T, the vertical motion unit is used. - // When the starting position is set to the upper right or lower left of the print area using ESC T, the horizontal motion unit is used. - return []byte{escpos.GS, '\\', byte(offset & 255), byte(offset >> 8 & 255)} -} -func offsetX(offset int) []byte { - // A positive number specifies movement to the right, and a negative number specifies movement to the left. - // When Standard mode is selected, the horizontal motion unit is used. - // when Page mode is selected, the horizontal or vertical motion unit is used for the print direction set by ESC T. - // When the starting position is set to the upper left or lower right of the print area using ESC T, the horizontal motion unit is used. - // When the starting position is set to the upper right or lower left of the print area using ESC T, the vertical motion unit is used. - return []byte{ESC, '\\', byte(offset & 255), byte(offset >> 8 & 255)} -} -func invert(n int) []byte { - //When the LSB of n is 0, white/black reverse print mode is turned off. - //n = 0 – 255 - return []byte{escpos.GS, byte('B'), byte(n)} -} -func disableSensors() []byte { - return []byte{ESC, 'c', '3', 0} -} -func printSpeed(m int) []byte { - // m = 0 – 9, 48 – 57 : slowest - fastest - // m = 0 - 13 : slowest - fastest version V - // [Default] 0 = Setting value of GS ( E customize value (a = 6) - // m = 0 - //Slower print speed seems to retain a bit more quality in dithered images. pure B/W images do not have a noticable difference - return []byte{escpos.GS, '(', 'K', 2, 0, 50, byte(m & 255), byte(m >> 8 & 255)} -} - -func main() { - f, err := os.OpenFile("/dev/usb/lp0", os.O_WRONLY|os.O_CREATE, 0) - if err != nil { - panic(err) - } - defer f.Close() - - //load image - imagef, err := os.Open("kia.png") - if err != nil { - panic(err) - } - defer imagef.Close() - img, _, err := image.Decode(imagef) - - ep := escpos.New(f) - - ep.Init() - ep.WriteRaw(pageWidth(int(math.Round((29.0 / 80.0) * 512)))) - ep.WriteRaw(pageMargin(1)) - ep.WriteRaw(printSpeed(13)) - // ditherer := ditherers[1] - // log.Println("Using ditherer type: " + ditherer.Type) - - // dg := ditherer.Monochrome(img, 1.18) - rasterConv := &raster.Converter{ - MaxWidth: 186, // == math.Round((29.0 / 80.0) * 512)) == 29mm sticker roll - Threshold: 0.1, //pre-dithered images are black or white anyway, so this can be extremely low as there won't be any in-between colors (default: 0.5) - } - for i := 0; i < 2; i++ { - rasterConv.Print(img, ep) - ep.Cut() - } - - //ep.WriteRaw([]byte{12}) // FF: in Page mode, prints all the data in the print buffer collectively and switches from Page mode to Standard mode. - //ep.Formfeed() - - ep.End() - -} - diff --git a/dim.go b/test_dnh.go similarity index 100% rename from dim.go rename to test_dnh.go diff --git a/trash.go b/trash.go deleted file mode 100644 index 4d2eb24..0000000 --- a/trash.go +++ /dev/null @@ -1,95 +0,0 @@ -package main - -import ( - _ "image/jpeg" - _ "image/png" //I'm needed - "os" - "github.com/kenshaw/escpos" -) - -const ESC = byte(27) - -func pageWidth(widht int) []byte { - return []byte{escpos.GS, 87, byte(widht), 0} -} -func pageMargin(margin int) []byte { - return []byte{escpos.GS, 76, byte(margin), 0} -} -func pageMode() []byte { - return []byte{ESC, 'L'} -} -func pageDirection(direction uint8) []byte { - // https://www.epson-biz.com/modules/ref_escpos/index.php?content_id=55 - return []byte{ESC, 'T', direction} -} -func pagePrintArea(x, y, width, height int) []byte { - return []byte{ESC, 'W', - byte(x & 255), byte(x >> 8 & 255), - byte(y & 255), byte(y >> 8 & 255), - byte(width & 255), byte(width >> 8 & 255), - byte(height & 255), byte(height >> 8 & 255)} -} -func offsetY(offset int) []byte { - // A positive number specifies movement downward, and a negative number specifies movement upward. - // The horizontal or vertical motion unit is used for the print direction set by ESC T. - // When the starting position is set to the upper left or lower right of the print area using ESC T, the vertical motion unit is used. - // When the starting position is set to the upper right or lower left of the print area using ESC T, the horizontal motion unit is used. - return []byte{escpos.GS, '\\', byte(offset & 255), byte(offset >> 8 & 255)} -} -func offsetX(offset int) []byte { - // A positive number specifies movement to the right, and a negative number specifies movement to the left. - // When Standard mode is selected, the horizontal motion unit is used. - // when Page mode is selected, the horizontal or vertical motion unit is used for the print direction set by ESC T. - // When the starting position is set to the upper left or lower right of the print area using ESC T, the horizontal motion unit is used. - // When the starting position is set to the upper right or lower left of the print area using ESC T, the vertical motion unit is used. - return []byte{ESC, '\\', byte(offset & 255), byte(offset >> 8 & 255)} -} -func invert(n int) []byte { - //When the LSB of n is 0, white/black reverse print mode is turned off. - //n = 0 – 255 - return []byte{escpos.GS, byte('B'), byte(n)} -} -func disableSensors() []byte { - return []byte{ESC, 'c', '3', 0} -} -func printSpeed(m int) []byte { - // m = 0 – 9, 48 – 57 : slowest - fastest - // [Default] 0 = Setting value of GS ( E customize value (a = 6) - // m = 0 - //Slower print speed seems to retain a bit more quality in dithered images. pure B/W images do not have a noticable difference - return []byte{escpos.GS, '(', 'K', 2, 0, 50, byte(m & 255), byte(m >> 8 & 255)} -} - -func main() { - f, err := os.OpenFile("/dev/usb/lp1", os.O_WRONLY|os.O_CREATE, 0) - if err != nil { - panic(err) - } - defer f.Close() - - ep := escpos.New(f) - - ep.Init() - ep.WriteRaw(pageMode()) - ep.WriteRaw(pageDirection(1)) - ep.WriteRaw(pagePrintArea(0, 0, 1000, 850)) - ep.WriteRaw(offsetY(30)) - ep.SetFontSize(1,1) - ep.Write("Sheduled for trashing\n") - ep.WriteRaw(offsetY(35)) - ep.SetFontSize(3,2) - ep.SetEmphasize(1) - ep.Write("Do Not Hack\n") - ep.SetEmphasize(0) - ep.WriteRaw(offsetY(15)) - ep.SetFontSize(1,1) - ep.Write("Remove label to keep - 2023-10-14 \n") - - ep.WriteRaw([]byte{12}) // FF: in Page mode, prints all the data in the print buffer collectively and switches from Page mode to Standard mode. - //ep.Formfeed() - - ep.Cut() - ep.End() - -} -