Initial commit for i0T.app and migration here with a fresh repo

This commit is contained in:
2026-05-17 13:51:17 -06:00
commit 0f66fbd9d8
12 changed files with 2146 additions and 0 deletions

View File

@@ -0,0 +1,81 @@
package printer
import "testing"
func TestParseTemps(t *testing.T) {
s := NewState()
s.Parse("ok T:201.3 /210.0 B:60.2 /60.0 @:127 B@:0")
if got := s.Temps["T"]; got.Current != 201.3 || got.Target != 210.0 {
t.Fatalf("hotend got %+v", got)
}
if got := s.Temps["B"]; got.Current != 60.2 || got.Target != 60.0 {
t.Fatalf("bed got %+v", got)
}
}
func TestParseSDProgress(t *testing.T) {
s := NewState()
s.Parse("SD printing byte 12345/100000")
if s.SDByte != 12345 || s.SDTotal != 100000 {
t.Fatalf("got byte=%d total=%d", s.SDByte, s.SDTotal)
}
if s.PrintState != StateSDPrinting {
t.Fatalf("expected SD printing state, got %v", s.PrintState)
}
if p := s.Progress(); p < 0.12 || p > 0.13 {
t.Fatalf("progress %f", p)
}
}
func TestParseNotSDPrinting(t *testing.T) {
s := NewState()
s.SDByte, s.SDTotal = 1, 2
s.PrintState = StateSDPrinting
s.Parse("Not SD printing")
if s.PrintState != StateIdle {
t.Fatalf("expected idle, got %v", s.PrintState)
}
}
func TestParseFirmware(t *testing.T) {
s := NewState()
s.Parse("FIRMWARE_NAME:Marlin 2.1.2 SOURCE_CODE_URL:github.com/foo")
if s.Firmware != "Marlin 2.1.2" {
t.Fatalf("got firmware %q", s.Firmware)
}
}
func TestParseFileOpened(t *testing.T) {
s := NewState()
s.Parse("File opened: benchy.gcode Size: 1234567")
if s.SDFilename != "benchy.gcode" {
t.Fatalf("got %q", s.SDFilename)
}
}
func TestParseSDFileListing(t *testing.T) {
s := NewState()
for _, line := range []string{
"Begin file list",
"BENCHY.GCO 1234567",
"XYZ_CAL.GCO 50000 \"XYZ Calibration.gcode\"",
"End file list",
"ok",
} {
s.Parse(line)
}
if s.SDListing {
t.Fatalf("expected SDListing false after End")
}
if len(s.SDFiles) != 2 {
t.Fatalf("got %d files: %+v", len(s.SDFiles), s.SDFiles)
}
if s.SDFiles[0].Name != "BENCHY.GCO" || s.SDFiles[0].Size != 1234567 {
t.Fatalf("entry 0: %+v", s.SDFiles[0])
}
if s.SDFiles[1].Name != "XYZ_CAL.GCO" ||
s.SDFiles[1].Size != 50000 ||
s.SDFiles[1].LongName != "XYZ Calibration.gcode" {
t.Fatalf("entry 1: %+v", s.SDFiles[1])
}
}