utils

package
v2.7.4+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 8, 2021 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvStylePath = "OCTOSCREEN_STYLE_PATH"
	EnvBaseURL   = "OCTOPRINT_HOST"
	EnvAPIKey    = "OCTOPRINT_APIKEY"
)

Required environment variables

View Source
const (
	EnvLogLevel      = "OCTOSCREEN_LOG_LEVEL"
	EnvLogFilePath   = "OCTOSCREEN_LOG_FILE_PATH"
	EnvResolution    = "OCTOSCREEN_RESOLUTION"
	EnvConfigFile    = "OCTOPRINT_CONFIG_FILE"
	EnvDisplayCursor = "DISPLAY_CURSOR"
)

Optional (but good to have) environment variables

View Source
const (
	ImageFolder = "images"
	CSSFilename = "style.css"
)
View Source
const INVALID_ENV_TOKEN = "!!!INVALID!!!"
View Source
const LabelImageSize = 20

LabelImageSize default width and height of the image for a LabelWithImage

View Source
const MIN_HOTEND_TEMPERATURE = 150.0
View Source
const MISSING_ENV_TOKEN = ">>MISSING<<"

Variables

View Source
var (
	StylePath    string
	WindowName   = "OctoScreen"
	WindowWidth  = 800
	WindowHeight = 480
)
View Source
var OctoScreenVersion = "2.7.4"

OctoScreenVersion is set during compilation.

Functions

func AttachToolheadButtonsToGrid

func AttachToolheadButtonsToGrid(toolheadButtons []*gtk.Button, grid *gtk.Grid)

func CheckIfHotendTemperatureIsTooLow

func CheckIfHotendTemperatureIsTooLow(client *octoprintApis.Client, extruderId, action string, parentWindow *gtk.Window) bool

func CleanHTML

func CleanHTML(html string) string

func CreateChangeToolheadButtonsAndAttachToGrid

func CreateChangeToolheadButtonsAndAttachToGrid(toolheadCount int, grid *gtk.Grid) []*gtk.Button

func CreateToolheadButton

func CreateToolheadButton(num, toolheadCount int, clicked func()) *gtk.Button

func CreateToolheadButtons

func CreateToolheadButtons(toolheadCount int) []*gtk.Button

func CreateToolheadButtonsAndAttachToGrid

func CreateToolheadButtonsAndAttachToGrid(toolheadCount int, grid *gtk.Grid) []*gtk.Button

**************************************************************************** Button Routines

func CreateUpdateTemperaturesBackgroundTask

func CreateUpdateTemperaturesBackgroundTask(
	temperatureDataDisplay interfaces.ITemperatureDataDisplay,
	client *octoprintApis.Client,
)

func DumpEnvironmentVariables

func DumpEnvironmentVariables()

func DumpSystemInformation

func DumpSystemInformation()

func EmptyTheContainer

func EmptyTheContainer(container *gtk.Container)

func ErrorMessageDialogBox

func ErrorMessageDialogBox(parentWindow *gtk.Window, message string)

func Extrude

func Extrude(
	client *octoprintApis.Client,
	isForward bool,
	extruderId string,
	parentWindow *gtk.Window,
	flowRatePercentage int,
	length int,
)

func FileExists

func FileExists(filename string) bool

FileExists checks if a file exists and is not a directory. From https://golangcode.com/check-if-a-file-exists/

func FolderExists

func FolderExists(filename string) bool

func GetCurrentTemperatureData

func GetCurrentTemperatureData(client *octoprintApis.Client) (map[string]dataModels.TemperatureData, error)

func GetDisplayNameForTool

func GetDisplayNameForTool(toolName string) string

func GetExtruderCount

func GetExtruderCount(client *octoprintApis.Client) int

func GetExtruderFileName

func GetExtruderFileName(hotendIndex, hotendCount int) string

func GetHasSharedNozzle

func GetHasSharedNozzle(client *octoprintApis.Client) bool

func GetHotendCount

func GetHotendCount(client *octoprintApis.Client) int

func GetHotendFileName

func GetHotendFileName(hotendIndex, hotendCount int) string

func GetNozzleFileName

func GetNozzleFileName(hotendIndex, hotendCount int) string

func GetObfuscatedValue

func GetObfuscatedValue(value string) string

func GetTemperatureDataString

func GetTemperatureDataString(temperatureData dataModels.TemperatureData) string

func GetToolTarget

func GetToolTarget(client *octoprintApis.Client, tool string) (float64, error)

func GetToolheadFileName

func GetToolheadFileName(hotendIndex, hotendCount int) string

func HotendTemperatureIsTooLow

func HotendTemperatureIsTooLow(
	temperatureData dataModels.TemperatureData,
	action string,
	parentWindow *gtk.Window,
) bool

func ImageFromUrl

func ImageFromUrl(imageUrl string) (*gtk.Image, error)

func InfoMessageDialogBox

func InfoMessageDialogBox(parentWindow *gtk.Window, message string)

func MustBox

func MustBox(orientation gtk.Orientation, spacing int) *gtk.Box

MustBox returns a new gtk.Box, with the given configuration, if err panics.

func MustButton

func MustButton(image *gtk.Image, clicked func()) *gtk.Button

func MustButtonImage

func MustButtonImage(buttonlabel, imageFileName string, clicked func()) *gtk.Button

func MustButtonImageStyle

func MustButtonImageStyle(buttonlabel, imageFileName string, style string, clicked func()) *gtk.Button

MustButtonImageStyle returns a new gtk.Button with the given label, image and clicked callback, if error panics.

func MustButtonText

func MustButtonText(label string, clicked func()) *gtk.Button

func MustCSSProviderFromFile

func MustCSSProviderFromFile(css string) *gtk.CssProvider

MustCSSProviderFromFile returns a new gtk.CssProvider for a given css file, if error panics.

func MustConfirmDialogBox

func MustConfirmDialogBox(parent *gtk.Window, msg string, cb func()) func()

**************************************************************************** DialogBox Routines

func MustGrid

func MustGrid() *gtk.Grid

MustGrid returns a new gtk.Grid, if error panics.

func MustImageFromFile

func MustImageFromFile(imageFileName string) *gtk.Image

MustImageFromFile returns a new gtk.Image based on the given file, if error panics.

func MustImageFromFileWithSize

func MustImageFromFileWithSize(imageFileName string, width, height int) *gtk.Image

func MustLabel

func MustLabel(format string, args ...interface{}) *gtk.Label

MustLabel returns a new gtk.Label, if err panics.

func MustLabelWithCssClass

func MustLabelWithCssClass(format string, className string, args ...interface{}) *gtk.Label

MustLabelWithCssClass returns a stylized new gtk.Label, if err panics.

func MustLabelWithCssClasses

func MustLabelWithCssClasses(format string, classNames []string, args ...interface{}) *gtk.Label

MustLabelWithCssClass returns a stylized new gtk.Label, if err panics.

func MustOverlay

func MustOverlay() *gtk.Overlay

MustOverlay returns a new gtk.Overlay, if error panics.

func MustProgressBar

func MustProgressBar() *gtk.ProgressBar

MustProgressBar returns a new gtk.ProgressBar, if err panics.

func MustToggleButton

func MustToggleButton(label string, imageFileName string, clicked func()) *gtk.ToggleButton

func MustWindow

func MustWindow(windowType gtk.WindowType) *gtk.Window

MustWindow returns a new gtk.Window, if error panics.

func NameOfMissingRequiredEnvironmentVariable

func NameOfMissingRequiredEnvironmentVariable(apiKey string) string

func RegisterTemperatureStatusBox

func RegisterTemperatureStatusBox(temperatureDataDisplay interfaces.ITemperatureDataDisplay, client *octoprintApis.Client)

func ReplaceHTMLTag

func ReplaceHTMLTag(html, from, to string) string

func RequiredEnvironmentVariablesAreSet

func RequiredEnvironmentVariablesAreSet(apiKey string) bool

func Round

func Round(num float64) int

func SelectTool

func SelectTool(
	client *octoprintApis.Client,
	extruderId string,
) error

func SendExtrudeRrequest

func SendExtrudeRrequest(
	client *octoprintApis.Client,
	isForward bool,
	length int,
) error

func SetFlowRate

func SetFlowRate(
	client *octoprintApis.Client,
	flowRatePercentage int,
) error

func SetToolTarget

func SetToolTarget(client *octoprintApis.Client, tool string, target float64) error

func StrEllipsis

func StrEllipsis(name string) string

TODO: Clean up StrEllipsis(), StrEllipsisLen(), and TruncateString() and consolidate into a single function.

func StrEllipsisLen

func StrEllipsisLen(name string, length int) string

func StructToJson

func StructToJson(obj interface{}) (string, error)

func ToFixed

func ToFixed(num float64, precision int) float64

func TruncateString

func TruncateString(str string, maxLength int) string

func WarningMessageDialogBox

func WarningMessageDialogBox(parentWindow *gtk.Window, message string)

Types

type BackgroundTask

type BackgroundTask struct {
	sync.Mutex
	// contains filtered or unexported fields
}
var UpdateTemperaturesBackgroundTask *BackgroundTask = nil

func CreateBackgroundTask

func CreateBackgroundTask(
	duration time.Duration,
	task func(),
) *BackgroundTask

func (*BackgroundTask) Close

func (this *BackgroundTask) Close()

func (*BackgroundTask) Start

func (this *BackgroundTask) Start()

type FileResponsesSortedByDate

type FileResponsesSortedByDate []*dataModels.FileResponse

func (FileResponsesSortedByDate) Len

func (this FileResponsesSortedByDate) Len() int

func (FileResponsesSortedByDate) Less

func (this FileResponsesSortedByDate) Less(i, j int) bool

func (FileResponsesSortedByDate) Swap

func (this FileResponsesSortedByDate) Swap(i, j int)

type FileResponsesSortedByName

type FileResponsesSortedByName []*dataModels.FileResponse

func (FileResponsesSortedByName) Len

func (this FileResponsesSortedByName) Len() int

func (FileResponsesSortedByName) Less

func (this FileResponsesSortedByName) Less(i, j int) bool

func (FileResponsesSortedByName) Swap

func (this FileResponsesSortedByName) Swap(i, j int)

type LabelWithImage

type LabelWithImage struct {
	Label *gtk.Label
	*gtk.Box
}

LabelWithImage represents a gtk.Label with a image to the right.

func MustLabelWithImage

func MustLabelWithImage(imageFileName, format string, args ...interface{}) *LabelWithImage

MustLabelWithImage returns a new LabelWithImage based on a gtk.Box containing a gtk.Label with a gtk.Image, the image is scaled at LabelImageSize.

type LocationHistory

type LocationHistory struct {
	Locations []dataModels.Location
}

func (*LocationHistory) CurrentLocation

func (this *LocationHistory) CurrentLocation() dataModels.Location

func (*LocationHistory) GoBack

func (this *LocationHistory) GoBack()

func (*LocationHistory) GoForward

func (this *LocationHistory) GoForward(folder string)

func (*LocationHistory) IsRoot

func (this *LocationHistory) IsRoot() bool

func (*LocationHistory) Length

func (this *LocationHistory) Length() int

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL