We have a driver for ILI9486 320×480 display and we can run Doton on it. But currently, it would use only half of the screen. Our window manager has hard-coded dimension 240×320.
We need to do something with it. I think we can update manager to calculate grid from dimensions and additionally we can add tiles auto positioning.
Why? Because it seems that not setting position on the screen can be better 🙂 System can add pages when required and take care of horizontal vs vertical position.
But I think that we should be able to set coords if we want to.
Source code @ GitHub
We have a touch driver in our GfxLCD package so we can upgrade Doton a little. We will add clickable widgets.
Our window managers will handle touch propagation. For the first widget with action, we will create a light switcher.
Source @ GitHub
This time we will finish what we started, the weather widget for Doton project:)
In part 1 we learned how to use endpoint to read current weather and forecast in browser and now lets make a python package.
But just before lets make few points.
- Our reader should work in background as thread,
- Have ability to read data for few cities
- Read data not in real time but with some frequency
Simple, we don’t want to send requests to openweathermap server with each call. It would be lame. Lets imagine that main loop is reading and displaying weather each second (on nice 20×4 LCD). Doing each second a call to remote server would take ages (ok few ms but way to long 🙂 ). We are asking for data and we want it now. And what is also important data wont change so often. We don’t need to have a fresh packet from server.
Lets start from something simple – current weather data for your city.
One of module in my project is used to gather weather information. I was looking for something free and good and found openweathermap.org. It has API, so all we need to know is how to work with this API and how we want to use informations.
In few parts I will try to describe API and show simple code to read weather.