In this article we will work on views and create our first view for home tab. We could put all code into one file but it would be a mess. So lets take a different approach, we will create a separate file for each view. Next we will work on button widget and create quit game action. Don’t forget that Piader is a tool to improve LCDManager.
Next widget we will add to our manager is pane (wrongly named panel before). It will allow us to create group of other widgets (label for now:)).
In this part we will focus on simple and quick implementation. In next part we will improve it.
After this we will rewrite Piader game to use manager and widgets. Somewhere between we will add event queue and probably refactor whole structure.
We have a simple virtual display. It can join lcds in one virtual area. But there is one catch. Look at the following layouts (red area is virtual lcd):
No problem. But what about:
… we can’t do it ! And what if we want to use this small 4×4 as second virtual display ? We can’t !
When we add lcd its added at any (x,y) but always starts from (0,0). Lets add an offset, so we can specify area.
Update – error in code. see at the bottom
We have a fully functional game that is quite primitive but don’t wory. We will do something about it and during this we will upgrade Lcd classes.
Remember draw function in game.py ? It was doing all kind of checks and distinctions between lcds. It shouldn’t be like that. Game class shouldn’t care about proper display, such task goes to lower level of code. From game perspective it should have some area to display and thats all. It should write on any (x, y) allowed by combined displays and don’t care which display is top, bottom, left or right.
Its time for Virtual Display 🙂
Today we will add player and it’s controls.
Controls, that’s something we will do a different way, we have no keyboard attached, no joystick and no pad. So what now ? Lets write a control server, a threaded class that will listen for control signals on some port. This way we will be able to use anything to move a player.
As first input we will use host keyboard, small class that will read keys and send them to game.
Download source code
So we can get weather data for our town and it would be good idea to display it somewhere. Time has come to dig into all kinds of LCDs. We will start from basic one – char LCD 20×4 based on HD44780.