NOKIA 5510 is a display in which pixels are portrait and pictures are not intended.
The actual pixel is indicated by REAL, and the feeling received from the display is Image.
I thought to make sense and pixels identical.
Is it okay if there is actually a paint tool that uses the screen of NOKIA 5510?
Let's do it for the time being.
this use gamebuino's screen and can draw a picture from the host (I use Raspberry Pi).
First of all, since it is necessary to send the status of the mouse serially on the host side, I will try to do it from here.
Because HOST is a raspberry pie, it is easy to handle Silial and other things. Let's try using Pi and PyGame.
PyGame is installed, but you need to prepare the wiringPi.
sudo pip install wiringpi2
I will try serial communication from python.
import wiringpi as wpi
sp=wpi.serialOpen("/dev/ttyACM0",9600)
wpi.serialPrintf(sp,"hello")
wpi.serialClose(sp)
OK, that's good.
Well, next.
You must detect the position of the mouse cursor and the pressing of the click button.
This is PyGame's job.
import wiringpi as wpi import pygame from pygame.locals import * #--------------------------------------------- # function start #--------------------------------------------- def pollingEvent(): global _running,position for event in pygame.event.get(): if event.type == pygame.QUIT: _running = False if event.type == pygame.MOUSEMOTION: position = event.pos button = event.buttons print("motion:",position,button) if event.type == pygame.MOUSEBUTTONDOWN: position = event.pos button = event.button print("DOWN:",position, button) if event.type == pygame.MOUSEBUTTONUP: position = event.pos button = event.button print("UP:",position, button) #--------------------------------------------- # function end #--------------------------------------------- _running = True _size = ( 320,200 ) _mode = pygame.HWSURFACE | pygame.DOUBLEBUF pygame.init() screen = pygame.display.set_mode(_size,_mode) pygame.display.set_caption("hello pygame") while(_running): pollingEvent() pygame.quit()
like this.
I have not done serial communication yet, but it will be roughly like this code.
Consider the protocol.
The necessary information is the button UP, DOWN, and the position of the cursor.
protocol (draft)
Send Data (2bytes)
SXXX XXXX NCYY YYYY
S:button status ( 0:up , 1:down)
X:position x ( 0 to 84 )
Y:position y ( 0 to 48 )
C:color ( 0 or 1 )
N: not use
For example, what happens when you use gray?
CC may be better than NC..