linestogo

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2021 License: MIT Imports: 17 Imported by: 0

README

linestogo

Go Reference

Tiny lib to manipulate the .line format (.rm in the reMarkable2) in Go

Example:

package main

import (
	"log"
	"os"

	"github.com/kr/pretty"
	linestogo "github.com/owulveryck/linesToGo"
)

func main() {
	p := &linestogo.Page{}
	err := linestogo.Read(os.Stdin, p)
	if err != nil {
		log.Fatal(err)
	}
	pretty.Print(p)
}

Documentation

Overview

package linestogo allows decoding a .line file format version=5 from the reMarkable 2 into a Go structure

for more info, please cf:

Example (StartPolling)
package main

import (
	"context"
	"log"

	linestogo "github.com/owulveryck/linesToGo"
)

func main() {
	ctx := context.Background()
	pageC, cancel, err := linestogo.StartPolling(ctx)
	if err != nil {
		log.Fatal(err)
	}
	defer cancel()
	for p := range pageC {
		log.Println("current page is:", p)
	}
}
Output:

Example (Svg)
package main

import (
	"encoding/xml"
	"log"
	"os"

	linestogo "github.com/owulveryck/linesToGo"
)

func main() {
	p := &linestogo.Page{}
	err := linestogo.Read(os.Stdin, p)
	if err != nil {
		log.Fatal(err)
	}
	enc := xml.NewEncoder(os.Stdout)
	enc.Indent("", "    ")
	err = enc.Encode(p)
	if err != nil {
		log.Fatal(err)
	}
	enc.Flush()
}
Output:

Index

Examples

Constants

View Source
const (
	XochitlCacheDir = `/home/root/.local/share/remarkable/xochitl`
)

Variables

Functions

func Read

func Read(r io.Reader, p *Page) error

Read from r and fill Page

func StartPolling added in v0.1.1

func StartPolling(ctx context.Context) (<-chan string, context.CancelFunc, error)

StartPolling triggers two go-routines:

The first goroutine monitors the XochitlCacheDir. It feeds a channel with the directory containing the last modified notebook (based on the metadata)

The seecond go-routine is reading the notebook directory from the previous channel and monitors it It feeeds the output channel with the name of the current file which is likely the current page.

Caution: the remarkable is writing *a lot*, so a 50ms timer is set to prevent sending too many events on the chan

Types

type Layer

type Layer struct {
	Strokes []*Stroke `protobuf:"bytes,1,rep,name=strokes,proto3" json:"strokes,omitempty"`
	// contains filtered or unexported fields
}

func (*Layer) Descriptor deprecated added in v0.1.1

func (*Layer) Descriptor() ([]byte, []int)

Deprecated: Use Layer.ProtoReflect.Descriptor instead.

func (*Layer) GetStrokes added in v0.1.1

func (x *Layer) GetStrokes() []*Stroke

func (*Layer) MarshalXML added in v0.1.0

func (l *Layer) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*Layer) ProtoMessage added in v0.1.1

func (*Layer) ProtoMessage()

func (*Layer) ProtoReflect added in v0.1.1

func (x *Layer) ProtoReflect() protoreflect.Message

func (*Layer) Reset added in v0.1.1

func (x *Layer) Reset()

func (*Layer) String added in v0.1.1

func (x *Layer) String() string

type Page

type Page struct {
	Header string   `protobuf:"bytes,1,opt,name=header,proto3" json:"header,omitempty"`
	Layers []*Layer `protobuf:"bytes,2,rep,name=layers,proto3" json:"layers,omitempty"`
	// contains filtered or unexported fields
}

func (*Page) Descriptor deprecated added in v0.1.1

func (*Page) Descriptor() ([]byte, []int)

Deprecated: Use Page.ProtoReflect.Descriptor instead.

func (*Page) GetHeader added in v0.1.1

func (x *Page) GetHeader() string

func (*Page) GetLayers added in v0.1.1

func (x *Page) GetLayers() []*Layer

func (*Page) MarshalXML added in v0.1.0

func (p *Page) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*Page) ProtoMessage added in v0.1.1

func (*Page) ProtoMessage()

func (*Page) ProtoReflect added in v0.1.1

func (x *Page) ProtoReflect() protoreflect.Message

func (*Page) Reset added in v0.1.1

func (x *Page) Reset()

func (*Page) String

func (x *Page) String() string

type RawPage added in v0.1.1

type RawPage struct {
	Page []byte `protobuf:"bytes,1,opt,name=page,proto3" json:"page,omitempty"`
	// contains filtered or unexported fields
}

func (*RawPage) Descriptor deprecated added in v0.1.1

func (*RawPage) Descriptor() ([]byte, []int)

Deprecated: Use RawPage.ProtoReflect.Descriptor instead.

func (*RawPage) GetPage added in v0.1.1

func (x *RawPage) GetPage() []byte

func (*RawPage) ProtoMessage added in v0.1.1

func (*RawPage) ProtoMessage()

func (*RawPage) ProtoReflect added in v0.1.1

func (x *RawPage) ProtoReflect() protoreflect.Message

func (*RawPage) Reset added in v0.1.1

func (x *RawPage) Reset()

func (*RawPage) String added in v0.1.1

func (x *RawPage) String() string

type Segment

type Segment struct {
	X         float32 `protobuf:"fixed32,1,opt,name=x,proto3" json:"x,omitempty"`
	Y         float32 `protobuf:"fixed32,2,opt,name=y,proto3" json:"y,omitempty"`
	Speed     float32 `protobuf:"fixed32,3,opt,name=speed,proto3" json:"speed,omitempty"`
	Width     float32 `protobuf:"fixed32,4,opt,name=width,proto3" json:"width,omitempty"`
	Direction float32 `protobuf:"fixed32,5,opt,name=direction,proto3" json:"direction,omitempty"`
	Pressure  float32 `protobuf:"fixed32,6,opt,name=pressure,proto3" json:"pressure,omitempty"`
	// contains filtered or unexported fields
}

func (*Segment) Descriptor deprecated added in v0.1.1

func (*Segment) Descriptor() ([]byte, []int)

Deprecated: Use Segment.ProtoReflect.Descriptor instead.

func (*Segment) GetDirection added in v0.1.1

func (x *Segment) GetDirection() float32

func (*Segment) GetPressure added in v0.1.1

func (x *Segment) GetPressure() float32

func (*Segment) GetSpeed added in v0.1.1

func (x *Segment) GetSpeed() float32

func (*Segment) GetWidth added in v0.1.1

func (x *Segment) GetWidth() float32

func (*Segment) GetX added in v0.1.1

func (x *Segment) GetX() float32

func (*Segment) GetY added in v0.1.1

func (x *Segment) GetY() float32

func (*Segment) ProtoMessage added in v0.1.1

func (*Segment) ProtoMessage()

func (*Segment) ProtoReflect added in v0.1.1

func (x *Segment) ProtoReflect() protoreflect.Message

func (*Segment) Reset added in v0.1.1

func (x *Segment) Reset()

func (*Segment) String added in v0.1.1

func (x *Segment) String() string

type Stroke

type Stroke struct {
	Pen         uint32     `protobuf:"varint,1,opt,name=pen,proto3" json:"pen,omitempty"`
	StrokeColor uint32     `protobuf:"varint,2,opt,name=stroke_color,json=strokeColor,proto3" json:"stroke_color,omitempty"`
	PenWidth    float32    `protobuf:"fixed32,3,opt,name=pen_width,json=penWidth,proto3" json:"pen_width,omitempty"`
	Segments    []*Segment `protobuf:"bytes,4,rep,name=segments,proto3" json:"segments,omitempty"`
	// contains filtered or unexported fields
}

func (*Stroke) Descriptor deprecated added in v0.1.1

func (*Stroke) Descriptor() ([]byte, []int)

Deprecated: Use Stroke.ProtoReflect.Descriptor instead.

func (*Stroke) GetPen added in v0.1.1

func (x *Stroke) GetPen() uint32

func (*Stroke) GetPenWidth added in v0.1.1

func (x *Stroke) GetPenWidth() float32

func (*Stroke) GetSegments added in v0.1.1

func (x *Stroke) GetSegments() []*Segment

func (*Stroke) GetStrokeColor added in v0.1.1

func (x *Stroke) GetStrokeColor() uint32

func (*Stroke) MarshalXML added in v0.1.0

func (s *Stroke) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML creates a SVG representation of the stroke

func (*Stroke) ProtoMessage added in v0.1.1

func (*Stroke) ProtoMessage()

func (*Stroke) ProtoReflect added in v0.1.1

func (x *Stroke) ProtoReflect() protoreflect.Message

func (*Stroke) Reset added in v0.1.1

func (x *Stroke) Reset()

func (*Stroke) String added in v0.1.1

func (x *Stroke) String() string

Directories

Path Synopsis
example
cmd
test

Jump to

Keyboard shortcuts

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