41 lines
888 B
Python
41 lines
888 B
Python
import sys, os, gc, optparse, logging, time
|
|
from cffi import FFI
|
|
import datetime
|
|
|
|
SCREEN_PATH="/home/pi/3dscreen"
|
|
|
|
ffi = FFI()
|
|
lib = None
|
|
|
|
def load():
|
|
global lib
|
|
|
|
ffi.cdef("""
|
|
char* Klippy_Get_Autosave_Filename();
|
|
char* Klippy_Autosave_Read();
|
|
bool Klippy_Autosave_Write(char*);
|
|
void free(void*);
|
|
""")
|
|
|
|
try:
|
|
lib = ffi.dlopen(SCREEN_PATH+"/lib/lib3dscreen.so")
|
|
except:
|
|
lib = ffi.dlopen("/lib/lib3dscreen-host.so")
|
|
|
|
def Klippy_Get_Autosave_Filename():
|
|
res = lib.Klippy_Get_Autosave_Filename()
|
|
s = ffi.string(res).decode("utf-8")
|
|
lib.free(res)
|
|
return s
|
|
|
|
def Klippy_Autosave_Read():
|
|
res = lib.Klippy_Autosave_Read()
|
|
s = ffi.string(res).decode("utf-8")
|
|
lib.free(res)
|
|
return s
|
|
|
|
def Klippy_Autosave_Write(data):
|
|
b = data.encode('utf-8')
|
|
res = lib.Klippy_Autosave_Write(b)
|
|
return res
|