1
0
mirror of https://github.com/mbirth/wipy-ussd1306.git synced 2024-12-24 22:44:05 +00:00

Added garbage collection to free up some memory before doing

memory-intensive tasks.
This commit is contained in:
Markus Birth 2016-04-09 16:35:51 +02:00
parent ec958f3808
commit d66498cb88

View File

@ -33,6 +33,7 @@ except:
# WiPy # WiPy
import machine import machine
import gc
import struct import struct
import time import time
@ -196,7 +197,9 @@ class SSD1306:
def clear(self): def clear(self):
""" clear screen """ """ clear screen """
self.position(0, 0) self.position(0, 0)
gc.collect()
self.data([0] * (self.height * self.width // 8)) self.data([0] * (self.height * self.width // 8))
gc.collect()
self.position(0, 0) self.position(0, 0)
def sleep_ms(self, mseconds): def sleep_ms(self, mseconds):
@ -259,6 +262,5 @@ class SSD1306:
arr = [dc] + arr arr = [dc] + arr
#print(repr(arr)) #print(repr(arr))
buf = struct.pack('B'*len(arr), *arr) buf = struct.pack('B'*len(arr), *arr)
print(repr(buf)) #print(repr(buf))
self.i2c.writeto(self.devid, buf) self.i2c.writeto(self.devid, buf)