A README.md => README.md +74 -0
@@ 0,0 1,74 @@
+# Simple clock
+This is just a small project that aims to make a simple clock, using STM32F103C8T6.
+The clock will be shown on a seven segment display. There will be multiple modes to show
+on the clock display.
+
+## HW
+STM32F103C8T6 is used as the _brains_. It has RTC that may be powered by CR2032 battery.
+It's connected to a USB header, allowing to communicate with a computer. The chip is capable
+of being a device, only, not host.
+There is a header with 3V3, SWDIO, SWCLK, GND to allow programming the chip using a tool such as STLink.
+ASM1117-3.3 is used for stepping down from 5V to 3V3.
+3V3 should not be connected whilst USB is connected as well. This would short output of the LDO to 3V3.
+There is no protection!
+
+There are 8 seven segment displays,
+4 of them are blue, 4 of them are yellow, the whole display looks like this: Y.Y.BB:BBY.Y.
+(Y for yellow digit, B for blue digit)
+There are 4 LEDs and 4 buttons, the LEDs are next to the buttons, making each LED "associated" with a button.
+That makes it possible to light up an LED next to button, if the button is pressed etc.
+
+The digits of the seven segment display are connected to PNP transistors.
+When pulling the pin connected to the transistor low, the digit is turned on.
+The pins used may be connected to timers, and PWM may be utilized to set
+brightness.
+Segments get turned on by being low as well.
+
+Mapping of pins to peripherals is documented in [pins](docs/pins.md).
+
+## Features / Roadmap
+
+- [-] Remember date, time
+ - [x] Time
+ - [-] Date (does not calculate months, years correctly)
+- [x] Switch between view modes by button
+- [x] Show time, date
+- [x] Adjust brightness using PWM
+- [x] Auto adjust brightness based on time
+- [ ] Stopwatch
+- [ ] USB communication
+ - [ ] Set time, Get time
+ - [ ] Show arbitrary text or number on the display
+ - [ ] Start stopwatch
+
+## Images of the clock
+### Front, off
+<img src="img/front_off.jpg" alt="Front, off" width=800>
+
+### Back
+<img src="img/back.jpg" alt="Back" width=800>
+
+### Front, with seconds
+<img src="img/front_seconds.jpg" alt="Front, with seconds" width=800>
+
+### Front, with clock and date
+<img src="img/front_clock_date.jpg" alt="Front, clock and date" width=800>
+
+## What's next
+Currently the project does not support setting the clock using the buttons,
+to set the clock, it's required to use `rtc.set_time` by flashing a program
+with this line. Then this line should be removed, that will ensure the clock is
+remembered even on power down - if battery is connected. For adjustments,
+a button has to be programmed to add/remove a second or two, to get the clock
+synchronized with real time.
+
+Unfortunately, I did not solder the USB correctly on my board, so I cannot
+currently test sending and receiving data using the USB, that is the reason
+why the current program does not even support USB. In the future, the firmware
+should support USB communication and a program for a computer should be made,
+with some kind of CLI for communication with the board.
+
+Another thing that could be done is a bit of a refactoring of the main function.
+I am quite new to Rust and I don't know how to split the initialization of peripherals
+to multiple functions _naturally_. Now the main function is very long, because all initialization
+is in there.
A docs/pins.md => docs/pins.md +38 -0
@@ 0,0 1,38 @@
+# Pin mapping
+
+## LEDs
+LED1 PB12
+LED2 PB11
+LED3 PB1
+LED4 PB0
+
+## Buttons
+SW1 PB15
+SW2 PB14
+SW3 PB13
+SW4 PC13
+
+## Seven segment display
+The display pins are supposed to all be open-drains.
+Individual segment is lit up by putting both the digit and segment on.
+Only one digit at a time is supposed to be lit up, by turning
+on multiple digits, it's possible.
+
+DIG1 PA6 TIM3 CH1
+DIG2 PA3 TIM2 CH4
+DIG3 PA7 TIM3 CH2
+DIG4 PA8 TIM1 CH1
+DIG5 PA9 TIM1 CH2
+DIG6 PA2 TIM2 CH3
+DIG7 PA10 TIM1 CH3
+DIG8 PA1 TIM2 CH2
+
+A PB10
+B PB2
+C PB8
+D PB6
+E PB9
+F PB3
+G PB4
+DP PB7
+
A img/back.jpg => img/back.jpg +0 -0
A img/front_clock_date.jpg => img/front_clock_date.jpg +0 -0
A img/front_off.jpg => img/front_off.jpg +0 -0
A img/front_seconds.jpg => img/front_seconds.jpg +0 -0
M source/Cargo.lock => source/Cargo.lock +5 -5
@@ 100,7 100,7 @@ dependencies = [
"proc-macro-error",
"proc-macro2",
"quote",
- "syn 2.0.27",
+ "syn 2.0.28",
]
[[package]]
@@ 353,7 353,7 @@ dependencies = [
[[package]]
name = "stm32f1xx-hal"
version = "0.10.0"
-source = "git+https://github.com/Rutherther/stm32f1xx-hal#68e27247b69e95c02d52228cc41ae5cb59b910db"
+source = "git+https://github.com/Rutherther/stm32f1xx-hal#92784400205068d616541d8806b2fb7d529e48a0"
dependencies = [
"bitflags",
"bxcan",
@@ 382,9 382,9 @@ dependencies = [
[[package]]
name = "syn"
-version = "2.0.27"
+version = "2.0.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b60f673f44a8255b9c8c657daf66a596d435f2da81a555b06dc644d080ba45e0"
+checksum = "04361975b3f5e348b2189d8dc55bc942f278b2d482a6a0365de5bdd62d351567"
dependencies = [
"proc-macro2",
"quote",
@@ 408,7 408,7 @@ checksum = "090198534930841fab3a5d1bb637cde49e339654e606195f8d9c76eeb081dc96"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.27",
+ "syn 2.0.28",
]
[[package]]