Does it feel like time is moving strangely during the pandemic?
For our first Pi project, we will pay homage to the timekeeping devices of old by making simple clocks.
It is worth spending a little time thinking about how you mark time, and what would be useful in a clock of your own design.
Please indicate anyone you collaborated with on this Lab here. Be generous in acknowledging their contributions! And also recognizing any other influences (e.g. from YouTube, Github, Twitter) that informed your design.
Lab prep is extra long this week! Make sure you read it over in time to prepare for lab on Wednesday.
If you are overseas, you should have already ordered your parts.
If you are remote but in the US, the teaching team mailed parts last week.
If you are in New York, you can pick up your parts. If you have not picked up your parts by class you should come to Tata 351.
- Pull changes from the Interactive Lab Hub so that you have your own copy of Lab 2 on your own lab hub. (This may have to be done again at the start of lab on Wednesday.)
In terminal cd into your Interactive-Lab-Hub folder and run
Interactive-Lab-Hub $ git remote add upstream https://github.com/FAR-Lab/Interactive-Lab-Hub.git
Interactive-Lab-Hub $ git pull upstream Spring2021
Interactive-Lab-Hub $ git add .
Interactive-Lab-Hub $ git commit -m'merge'
Interactive-Lab-Hub $ git push
Your local and remote should now be up to date with the most recent files.
- Go to the lab prep page to inventory your parts and set up your Pi.
For this assignment, you are going to
E) Modify the code to make the display your own
F) Make a short video of your modified barebones PiClock
G) Sketch and brainstorm further interactions and features you would like for your clock for Part 2.
This readme.md page in your own repository should be edited to include the work you have done. You can delete everything but the headers and the sections between the stars. Write the answers to the questions under the starred sentences. Include any material that explains what you did in this lab hub folder, and link it in the readme.
Labs are due on Mondays. Make sure this page is linked to on your main class hub page.
Just like you did in the lab prep, ssh on to your pi. Once there create a Python environment.
ssh pi@ixe00
pi@ixe00:~ $ virtualenv circuitpython
pi@ixe00:~ $ source circuitpython/bin/activate
(circuitpython) pi@ixe00:~ $
Clone the repo for this assignment
(circuitpython) pi@ixe00:~$ git clone https://github.com/YOURGITID/Interactive-Lab-Hub.git
(circuitpython) pi@ixe00:~$ cd Interactive-Lab-Hub/Lab\ 2/
(circuitpython) pi@ixe00:~/Interactive-Lab-Hub $
Install the packages from the requirements.txt and run the example
(circuitpython) pi@ixe00:~/Interactive-Lab-Hub $ pip install -r requirements.txt
(circuitpython) pi@ixe00:~/Interactive-Lab-Hub/Lab 2 $ python cli_clock.py
02/24/2021 11:20:49
you can press ctrl-c
to exit.
If you're unfamiliar with the Python code in cli_clock.py
have a look at this Python refresher. If you're still concerned, please reach out to the teaching staff!
We will introduce you to the Adafruit MiniPiTFT and Python on the Pi.
The Raspberry Pi 4 has a variety of interfacing options. When you plug the pi in the red power LED turns on. Any time the SD card is accessed the green LED flashes. It has standard USB ports and HDMI ports. Less familiar it has a set of 20x2 pin headers that allow you to connect a various peripherals.
To learn more about any individual pin and what it is for go to pinout.xyz and click on the pin. Some terms may be unfamiliar but we will go over the relevant ones as they come up.
From your kit take out the display and the [Raspberry Pi 4](https://www.adafruit.com/product/4296 | width=200)
Line up the screen and press it on the headers. The hole in the screen should match up with the hole on the raspberry pi.
The display uses a communication protocol called SPI to speak with the raspberry pi. We won't go in depth in this course over how SPI works. The port on the bottom of the display connects to the SDA and SCL pins used for the I2C communication protocol which we will cover later. GPIO (General Purpose Input/Output) pins 23 and 24 are connected to the two buttons on the left. GPIO 22 controls the display backlight.
We can test it by typing
python screen_test.py
You can type the name of a color then press either of the buttons to see what happens on the display. Take a look at the code with
cat screen_test.py
You can look in stats.py
for how to display text on the screen
You can look in image.py
for an example of how to display an image on the screen. Can you make it switch to another image when you push one of the buttons?
In screen_clock.py
. Show the time by filling in the while loop. You can use the code in cli_clock.py
and stats.py
to figure this out.
Does time have to be linear? How do you measure a year? In daylights? In midnights? In cups of coffee?
Can you make time interactive? You can look in screen_test.py
for examples for how to use the buttons.
A copy of your code should be in your Lab 2 Github repo.
You can push to your personal github repo by adding the files here, commiting and pushing.
git add .
git commit -m'your message here'
git push
After that, git will ask you to login to your github account to upload.
Take a video of your PiClock.
-
Pick up remaining parts for kit.
-
Look at and give feedback on the Part G. for at least 2 other people in the class (and get 2 people to comment on your Part G!)
Pull Interactive Lab Hub updates to your repo.
Modify the code from last week's lab to make a new visual interface for your new clock. You may extend the Pi by adding sensors or buttons, but this is not required.
As always, make sure you document contributions and ideas from others explicitly in your writeup.
Buildiing up from part 1, the clock now can interact with the weather, sunrise and sunset in real time by changing the clock's colors. The Pi clock I designed is a colorful numeric clock that can change color over time based on the time of a day, sunset, sunrise, and weather forecast. The clock can update the sunrise and sunset time based on your location making use of the suntime library.
In a sunny morning and it is a sunny day, the clock looks like this:
In a sunny noon, the clock looks like this:
In a sunny afternoon, the clock looks like this:
In a sunny later afternoon, the clock looks like this:
After sunset, in a cloudy night, the clock looks like this:
After midnight, in a cloudy night, the clock looks like this:
Feedback from Renzhi Hu: Hi Panda, I think your clock has a nice interface and cool features. The sunrise/sunset time and change of color are so cool. My suggestion for improvement is you could make use of both buttons to include more functionalities, such as a stopwatch, alarm, etc. Looking forward to your progress!
Feedback from Songyu Du: Hi Panda, your clock provided users with a really good amount of information about time. Both the icon indicating day/night, and the changing color of the clock based off time made this clock informative. Maybe you could try to add more features like weather or world clock by utilizing the buttons for user interaction.
You are permitted (but not required) to work in groups and share a turn in; you are expected to make equal contribution on any group work you do, and N people's group project should look like N times the work of a single person's lab. What each person did should be explicitly documented. Make sure the page for the group turn in is linked to your Interactive Lab Hub page.