diff --git a/.gitignore b/.gitignore index e6b0faa72..831b8b83a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ *.o *.a *.so +*.sw[pc] /led-matrix /minimal-example /text-example diff --git a/rgbmatrix.cc b/rgbmatrix.cc index 9fdd545d6..423bcb3b0 100644 --- a/rgbmatrix.cc +++ b/rgbmatrix.cc @@ -10,6 +10,7 @@ #include #include #include "led-matrix.h" +#include "graphics.h" using rgb_matrix::GPIO; using rgb_matrix::RGBMatrix; @@ -17,8 +18,8 @@ using rgb_matrix::RGBMatrix; static GPIO io; typedef struct { // Python object for matrix - PyObject_HEAD - RGBMatrix *matrix; + PyObject_HEAD + RGBMatrix *matrix; } RGBmatrixObject; // Rows & chained display values are currently both required parameters. @@ -105,7 +106,7 @@ static PyObject *SetPixel(RGBmatrixObject *self, PyObject *arg) { } // Copy whole display buffer to display from a list of bytes [R1,G1,B1,R2,G2,B2...] -static PyObject *SetBuffer(RGBmatrixObject *self, PyObject *data) +static PyObject *SetBuffer(RGBmatrixObject *self, PyObject *data) { Py_ssize_t count; int w, h, offset, y, x; @@ -122,9 +123,9 @@ static PyObject *SetBuffer(RGBmatrixObject *self, PyObject *data) return NULL; } - for(y=0; ymatrix, font, x, y + font.baseline(), color, utf8_text); + } + // TODO pass the integer returned by DrawText back to Python + + Py_INCREF(Py_None); + return Py_None; +} + static PyMethodDef methods[] = { { "Clear" , (PyCFunction)Clear , METH_NOARGS , NULL }, { "Fill" , (PyCFunction)Fill , METH_VARARGS, NULL }, @@ -257,6 +281,7 @@ static PyMethodDef methods[] = { { "SetImage" , (PyCFunction)SetImage , METH_VARARGS, NULL }, { "SetPWMBits" , (PyCFunction)SetPWMBits , METH_VARARGS, NULL }, { "SetWriteCycles", (PyCFunction)SetWriteCycles, METH_VARARGS, NULL }, + { "DrawText" , (PyCFunction)DrawText , METH_VARARGS, NULL }, { NULL, NULL, 0, NULL } }; diff --git a/texttest.py b/texttest.py new file mode 100644 index 000000000..8a3e34774 --- /dev/null +++ b/texttest.py @@ -0,0 +1,17 @@ +#!/usr/bin/python + +import sys, time +from rgbmatrix import Adafruit_RGBmatrix + +font_width = 4 +font_height = 6 +lines = ["Hi Mom!", "I'm cool."] + +matrix = Adafruit_RGBmatrix(16, 1) +bdf_font_file = "fonts/{0}x{1}.bdf".format(font_width, font_height) +matrix.DrawText(bdf_font_file, 1, 1, 0xFF, 0xFF, 0, lines[0]) +time.sleep(2.0) +matrix.DrawText(bdf_font_file, 1, 1 + font_height, 0xFF, 0, 0xFF, lines[1]) +time.sleep(10.0) + +matrix.Clear()