//go:build gopher_badge || nicenano // +build gopher_badge nicenano package main import ( "image/color" "time" "tinygo.org/x/tinyfont" "tinygo.org/x/tinyfont/freesans" qrcode "github.com/skip2/go-qrcode" ) func Info() { qrSize := int16(180) if displayHeight < 200 { qrSize = displayHeight - 5 } qr, err := qrcode.New("https://gopherbadge.com/", qrcode.Medium) if err != nil { println(err, 123) } qrbytes := qr.Bitmap() size := int16(len(qrbytes)) factor := qrSize / size bx := (qrSize - size*factor) / 2 by := (qrSize - size*factor) / 2 display.FillScreen(color.RGBA{109, 0, 140, 255}) for y := int16(0); y < size; y++ { for x := int16(0); x < size; x++ { if qrbytes[y][x] { display.FillRectangle(bx+x*factor, by+y*factor, factor, factor, colorBlack) } else { display.FillRectangle(bx+x*factor, by+y*factor, factor, factor, colorWhite) } } } w32, _ := tinyfont.LineWidth(&freesans.Bold18pt7b, "SCAN") tinyfont.WriteLine(&display, &freesans.Bold18pt7b, qrSize+((displayWidth-qrSize)-int16(w32))/2, 45, "SCAN", colorWhite) w32, _ = tinyfont.LineWidth(&freesans.Bold18pt7b, "ME") tinyfont.WriteLine(&display, &freesans.Bold18pt7b, qrSize+((displayWidth-qrSize)-int16(w32))/2, 80, "ME", colorWhite) if displayHeight >= 200 { w32, _ = tinyfont.LineWidth(&freesans.Bold9pt7b, "Press any") tinyfont.WriteLine(&display, &freesans.Bold9pt7b, qrSize+((displayWidth-qrSize)-int16(w32))/2, 120, "Press any", colorWhite) w32, _ = tinyfont.LineWidth(&freesans.Bold9pt7b, "button") tinyfont.WriteLine(&display, &freesans.Bold9pt7b, qrSize+((displayWidth-qrSize)-int16(w32))/2, 140, "button", colorWhite) w32, _ = tinyfont.LineWidth(&freesans.Bold9pt7b, "to continue") tinyfont.WriteLine(&display, &freesans.Bold9pt7b, qrSize+((displayWidth-qrSize)-int16(w32))/2, 160, "to continue", colorWhite) w32, _ = tinyfont.LineWidth(&freesans.Bold9pt7b, "Visit https://gopherbadge.com/") tinyfont.WriteLine(&display, &freesans.Bold9pt7b, (displayWidth-int16(w32))/2, qrSize+25, "Visit https://gopherbadge.com/", colorWhite) w32, _ = tinyfont.LineWidth(&freesans.Bold9pt7b, "for more information") tinyfont.WriteLine(&display, &freesans.Bold9pt7b, (displayWidth-int16(w32))/2, qrSize+45, "for more information", colorWhite) } for { time.Sleep(100 * time.Millisecond) getInput() if goBack() { quit = true return } } }