diff --git a/README.md b/README.md index a34d32a..794a8c9 100644 --- a/README.md +++ b/README.md @@ -205,10 +205,3 @@ The command line tool is designed to be used in a 'pipeline' style, for example: Known resins: (from local user ChiTuBox config) - Profile bottom 5 layers, 50; nominal 15 - Voxelab Black for 0.05mm bottom 6 layers, 50; nominal 10 - Voxelab Green for 0.05mm bottom 6 layers, 50; nominal 10 - Voxelab Grey for 0.05mm bottom 6 layers, 50; nominal 8 - Voxelab Red for 0.05mm bottom 6 layers, 50; nominal 10 - Voxelab Transparent for 0.05mm bottom 6 layers, 50; nominal 10 - Voxelab White for 0.05mm bottom 6 layers, 50; nominal 9 diff --git a/cmd/uv3dp/info.go b/cmd/uv3dp/info.go index dc05df2..b4f416a 100644 --- a/cmd/uv3dp/info.go +++ b/cmd/uv3dp/info.go @@ -37,7 +37,22 @@ func NewInfoCommand() (info *InfoCommand) { return } +func printExposure(mode string, exp *uv3dp.Exposure) { + fmt.Printf("%v:\n", mode) + fmt.Printf(" Exposure: %.2gs on, %.2gs off", exp.LightOnTime, exp.LightOffTime) + if exp.LightPWM != 255 { + fmt.Printf(", PWM %v", exp.LightPWM) + } + fmt.Printf(" Lift: %v mm, %v mm/min\n", + exp.LiftHeight, exp.LiftSpeed) + fmt.Printf(" Retract: %v mm, %v mm/min\n", + exp.RetractHeight, exp.RetractSpeed) +} + func (info *InfoCommand) Filter(input uv3dp.Printable) (output uv3dp.Printable, err error) { + exp := input.Exposure() + bot := input.Bottom() + if info.SizeSummary { size := input.Size() fmt.Printf("Layers: %v, %vx%v slices, %.2f x %.2f x %.2f mm bed required\n", @@ -55,27 +70,8 @@ func (info *InfoCommand) Filter(input uv3dp.Printable) (output uv3dp.Printable, } if info.ExposureSummary { - exp := input.Exposure() - bot := input.Bottom() - - fmt.Printf("Exposure: %.2gs on, %.2gs off", - exp.LightOnTime, - exp.LightOffTime) - if exp.LightPWM != 255 { - fmt.Printf(", PWM %v", exp.LightPWM) - } - fmt.Println() - fmt.Printf("Bottom: %.2gs on, %.2gs off", - bot.Exposure.LightOnTime, - bot.Exposure.LightOffTime) - if bot.Exposure.LightPWM != 255 { - fmt.Printf(", PWM %v", bot.Exposure.LightPWM) - } - fmt.Printf(" (%v layers)\n", bot.Count) - fmt.Printf("Lift: %v mm, %v mm/min\n", - exp.LiftHeight, exp.LiftSpeed) - fmt.Printf("Retract: %v mm, %v mm/min\n", - exp.RetractHeight, exp.RetractSpeed) + printExposure(fmt.Sprintf("Bottom (%v layers)", bot.Count), &bot.Exposure) + printExposure("Normal", &exp) keys := input.MetadataKeys() diff --git a/ctb/format.go b/ctb/format.go index 1ecd446..fc9ff2b 100644 --- a/ctb/format.go +++ b/ctb/format.go @@ -37,7 +37,7 @@ const ( type ctbHeader struct { Magic uint32 // 00: - Version uint32 // 04: Always '2' + Version uint32 // 04: Always '3' BedSizeMM [3]float32 // 08: _ [2]uint32 // 14: HeightMM float32 // 1c: @@ -220,7 +220,6 @@ func (cf *Formatter) Encode(writer uv3dp.Writer, printable uv3dp.Printable) (err return base } - base += uint32(previewSize) size := pic.Bounds().Size() if size == image.Pt(0, 0) { return base @@ -232,6 +231,8 @@ func (cf *Formatter) Encode(writer uv3dp.Writer, printable uv3dp.Printable) (err return base } + base += uint32(previewSize) + rleHash[hash] = rleInfo{offset: base, rle: rle} rleHashList = append(rleHashList, hash) @@ -246,7 +247,14 @@ func (cf *Formatter) Encode(writer uv3dp.Writer, printable uv3dp.Printable) (err previewHugeBase := headerBase + uint32(headerSize) previewTinyBase := savePreview(previewHugeBase, &previewHuge, uv3dp.PreviewTypeHuge) + if previewTinyBase == previewHugeBase { + previewHugeBase = 0 + } + paramBase := savePreview(previewTinyBase, &previewTiny, uv3dp.PreviewTypeTiny) + if paramBase == previewTinyBase { + previewTinyBase = 0 + } param := ctbParam{} paramSize, _ := restruct.SizeOf(¶m) @@ -440,8 +448,13 @@ func (cf *Formatter) Encode(writer uv3dp.Writer, printable uv3dp.Printable) (err fileData[base], _ = restruct.Pack(binary.LittleEndian, &layer) } - fileData[int(previewHugeBase)], _ = restruct.Pack(binary.LittleEndian, &previewHuge) - fileData[int(previewTinyBase)], _ = restruct.Pack(binary.LittleEndian, &previewTiny) + if previewHugeBase > 0 { + fileData[int(previewHugeBase)], _ = restruct.Pack(binary.LittleEndian, &previewHuge) + } + + if previewTinyBase > 0 { + fileData[int(previewTinyBase)], _ = restruct.Pack(binary.LittleEndian, &previewTiny) + } for _, hash := range rleHashList { info := rleHash[hash] @@ -623,7 +636,7 @@ func (cf *Formatter) Decode(file uv3dp.Reader, filesize int64) (printable uv3dp. var param ctbParam addr := int(header.ParamOffset) - err = restruct.Unpack(data[addr:], binary.LittleEndian, ¶m) + err = restruct.Unpack(data[addr:addr+int(header.ParamSize)], binary.LittleEndian, ¶m) if err != nil { return }