Megapi python


#1

hi everyone.
I build a bot with megapiboard
I try to program it with python

I don t understand when I use “ledMatrixDisplayRaw” in my script .
python tell me
Traceback (most recent call last):
File “C:\Users\prouz\OneDrive\Documents\python_windows\megapi 2019\megapi 2019.py”, line 110, in
ecran()
File “C:\Users\prouz\OneDrive\Documents\python_windows\megapi 2019\megapi 2019.py”, line 49, in ecran
bot.ledMatrixDisplayRaw(8,1);
AttributeError: ‘MegaPi’ object has no attribute ‘ledMatrixDisplayRaw’

I don t understand what can I do to fix it?


#2

If i look at the python 3 code on GitHub, it shows the following:
def ledMatrixMessage(self,port,x,y,message):
arr = list(message);
for i in range(len(arr)):
arr[i] = ord(arr[i]);
self.__writePackage(bytearray([0xff,0x55,8+len(arr),0,0x2,41,port,1,self.char2byte(x),self.char2byte(7-y),len(arr)]+arr))

def ledMatrixDisplay(self,port,x,y,buffer):
    self.__writePackage(bytearray([0xff,0x55,7+len(buffer),0,0x2,41,port,2,x,7-y]+buffer))

I do not see any code for ledMatrixDisplayRaw

I suggest that you test with the following:
from megapi import *

if name == ‘main’:
bot = MegaPi()
bot.start()
t = 16;
while True:
sleep(0.06);
bot.ledMatrixMessage(6,t,0,“Hello World”);
t-=1;
if(t<-68):
t = 16;


#3

on this website https://github.com/Makeblock-official/PythonForMegaPi , just after
def ledMatrixMessage(self,port,x,y,message)
there is ledMatrixDisplayRaw ( port, buffer )
I would like to use it to draw on the led matrix , can you do it with “def ledMatrixMessage(self,port,x,y,message)”?


#4

I realise my mistake it s ledMatrixDisplay(self,port,x,y,buffer)
anyone can explain me how to draw a smiley or something else please
I don t understand how can I do It.


#5

look at this info. You have to fill in the values in the buffer

https://www.generationrobots.com/media/mbot-led-matrix-instructions-generation-robots.pdf


#6

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.