Contents:
1.1 Hardware connection to Raspberry 40 pin extension.
1.2. Enable SPI, I2C and DTBO in Raspberry config.
1.3. Disable time synchronization on Raspberry.
1.5. Removing the module from memory
2.1.4. Temperature and Pressure
VDD3.3-> 3,3v (pin 1)
CS -> SPI0_CE0 (pin 24)
SCL -> SPI0_SCLK (pin 23)
SDA -> SPI0_MOSI (pin 19)
RS -> GPIO_23 (pin 16)
RST -> GPIO_24 (pin 18)
GND -> GROUND (pin 25)
VIN -> 3,3v (pin 1)
GND -> GROUND (pin 25)
SCL -> SCL1 i2c (pin 5)
SDA -> SDA1 i2c (pin 3)
VCC-> 3,3v (pin 1)
GND -> GROUND (pin 25)
SCL -> SCL1 i2c (pin 5)
SDA -> SDA1 i2c (pin 3)
AD0 -> 3,3v (pin 1)
+ -> 3,3v (pin 1)
- -> GROUND (pin 25)
C -> SCL1 i2c (pin 5)
D -> SDA1 i2c (pin 3)
Pin1 -> 3,3v (pin 1)
Pin2 -> GPIO_17 (pin 11)
you can enable SPI, I2C from the /boot/config.txt file. Open a terminal window and enter:
sudo nano /boot/config.txt
Look for a line that reads #dtparam=spi=on and remove the # symbol. Do the same for #dtparam=i2c=on and
dtparam=i2c_vc=on. Now add a line with dtoverlay=smart_clock.dtbo so dtbo overlay will be connected at boot time
Reboot your Pi.
By default, Raspberry is using time-synchronization service while connected to network.
We need to disable it, because time we use from rtc clock.
sudo systemctl stop systemd-timesyncd
sudo systemctl disable systemd-timesyncd
Building the Module and device-tree overlay:
-
make [KDIR=[Path to your linux kernel]]
-
The module will be compiled to smart_clock.ko
-
The device tree overlay will be compiled to smart_clock.dtbo
-
Copy smart_clock.dtbo to boot/overlays directory to the device
-
Inserting into your kernel:
Type command in terminal:
sudo insmod smart_clock.ko
After check kernel log if device is properly booted:
smart_clock: smart_clock: Major = 238 Minor = 0
smart_clock: gpio_button: found gpio #17 value in DT
smart_clock: st7735fb: init
smart_clock: st7735fb: probe started
st7735fb spi0.0: SPI ok
smart_clock: st7735fb: Total vm initialized 40960
smart_clock: bmp280: probing
smart_clock: bmp280: probed
smart_clock: ds3231: probing
smart_clock: ds3231: probed
smart_clock: ds3231: set time of the day from RTC result 0
smart_clock: mpu6050: probing
smart_clock: mpu6050: probed
if some of devices will fail to start, you will get the message with hardware name: probe failed. Check hardware connection or config.txt
If "set time of the day from RTC" result is other than 0 than your rtc is not activated or battery is too low, once you setup clock or alarm this will be fixed automatically.
Command:
sudo rmmod smart_clock.ko
module will be removed when the last timer is stopped. Check kernel log if device is properly removed:
smart_clock: controls unloaded
smart_clock: sensors unloaded
smart_clock: gpio_button: device exit
smart_clock: st7735fb: exiting
smart_clock: st7735fb: unloaded
smart_clock: module unloaded
entertainment part. Functions:
-Time
-Alarm
-Timer
-Temperature and Pressure
-Pedometer (Steps meter)
-Game
-Making of screenshot (BMP format) (2.1.7)
-Display BMP files (2.1.7)
-24h or AM/PM
-Temperature view in C/F
-Enable or disable the Alarm
-click (Short press)
-middle-long (Press and hold about 1 sec)
-long click (Press and hold longer than 1 sec)
Hold the button longer than 1 sec to enter first view mode.
Current time will be loaded from "rtc"
Clock view can be customized by showing time in format 24h or AM/PM
In Options view.
Adjusting the time:
Use middle-long button action to enter adjustments mode.
Adjustment's part will be blinking. Press short the button to adjust.
To switch the adjustments to the next part hold button long click
1st adjustments will be minutes, 2nd - hours, 3rd day of the month, 4th the month, 5th year (year is capped to 2050)
Once you finish the adjustments - clock value will be automatically stored in rtc.
Use long click to switch mode to next mode: Timer
Timer can be started and stopped by short pressing of the button.
To reset the timer -stop timer and use middle-long button action.
Timer can be run in background while view is switched. Use long-press button action while timer is running to switch the view while timer is running in background. The notification of running timer will be shown in notification bar.
Switch to the next view Alarm press long press button.
The alarm can be turned on and off in Options view.
When Alarm is triggered the message "ALARM !!!" will appear blinking on screen, short press the button to disable it.
Adjusting the alarm
Use middle-long click to enter adjustments mode.
Adjustment's part will be blinking. Press short the button to adjust.
To switch the adjustments to the next part hold button long action
1st adjustments will be minutes, 2nd -- hours
Once you finish the adjustments -- alarm values will be automatically stored in rtc.
Temperature can be shown in C or F. Check Options for the option.
Switch the next view Pedometer press long-press button.
Pedometer or Step meter shows steps (or vertical shakes) from the device start.
To reset the pedometer short press the button.
Switch the next view Game press long-press button.
Besides of pedometer the mpu6050 is also used for the control of the game "SNAKE".
Tilt the device left, right, up, down to control the snake and eat the fruit.
Once snake eats herself or touches the white merges -- the game will be over.
To Restart game short press the button.
Switch the next view Options press long-press button.
Adjusting the options:
Use middle-long click to enter adjustments mode.
Adjustment's part will be blinking. Press short the button to adjust.
To switch the adjustments to the next part hold button long click
Note: Once you finish the adjustments -- alarm values will be automatically stored in rtc.
Use terminal in your Raspberry to type the command:
cat dev/smart-clock
to get file stream of bmp image of your current screen.
Example:
cat dev/smart_clock > screen.bmp
It will create new file screen.bmp with the screenshot from your device.
Use terminal in your Raspberry to print to device the command:
cat screen.bmp > dev/smart_clock
The file will be displayed on screen.
Note: Only files with resolution less than 160x128 are supported. Otherwise, you will receive the error message.
When alarm is enabled in options -- the icon "Alarm" will be shown is notification bar on screen.
When timer is running in background -- the icon "Clock" will be blinking in notification bar on screen.